/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.co.pas.spaceandtime.data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;

/**
 *
 * @author alabuschagne
 */
@Entity
public class RoomExtra implements Serializable
{

    private static final long serialVersionUID = 1L;
    private Long id;
    private ExtraType extraType;
    private BigDecimal price;
    private Calendar startingDate;
    private Calendar endingDate;
    private Integer priority;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RoomExtra))
        {
            return false;
        }
        RoomExtra other = (RoomExtra) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd");
        if (extraType != null)
        {
            sb.append(extraType.getName());
        }
        else
        {
            sb.append("No extra type");
        }
        sb.append(" | ");
        if (startingDate != null)
        {
            sb.append(sdf.format(startingDate.getTime()));
        }
        else
        {
            sb.append("No starting date");
        }
        sb.append(" | ");
        if (endingDate != null)
        {
            sb.append(sdf.format(endingDate.getTime()));
        }
        else
        {
            sb.append("No ending date");
        }
        sb.append(" | ");
        if (priority != null)
        {
            sb.append(priority.toString());
        }
        else
        {
            sb.append("No priority");
        }

        sb.append(" | ");
        if (price != null)
        {
            sb.append(price.toString());
        }
        else
        {
            sb.append("No price");
        }
        return sb.toString();

    }

   

    /**
     * @return the extra
     */
    @ManyToOne
    public ExtraType getExtraType()
    {
        return extraType;
    }

    /**
     * @param extra the extra to set
     */
    public void setExtraType(ExtraType extra)
    {
        this.extraType = extra;
    }

    /**
     * @return the price
     */
    public BigDecimal getPrice()
    {
        return price;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(BigDecimal price)
    {
        this.price = price;
    }

    /**
     * @return the startingDate
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    public Calendar getStartingDate()
    {
        return startingDate;
    }

    /**
     * @param startingDate the startingDate to set
     */
    public void setStartingDate(Calendar startingDate)
    {
        this.startingDate = startingDate;
    }

    /**
     * @return the endingDate
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    public Calendar getEndingDate()
    {
        return endingDate;
    }

    /**
     * @param endingDate the endingDate to set
     */
    public void setEndingDate(Calendar endingDate)
    {
        this.endingDate = endingDate;
    }

    /**
     * @return the priority
     */
    public Integer getPriority()
    {
        return priority;
    }

    /**
     * @param priority the priority to set
     */
    public void setPriority(Integer priority)
    {
        this.priority = priority;
    }
}
